/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rbh.risk.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/**
 *
 * @author M
 */
@Entity
@Table(name = "rbh_risk_severity_level_detail")
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
@XmlRootElement
public class SeverityLevelDetail implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "SLDETAIL_ID", unique = true, nullable = false, columnDefinition = "smallint UNSIGNED")
    private Short sldetailId;
    @Column(name = "SLDETAIL_EXPLANATION", nullable = false, length = 2048)
    private String slDetailExplanation;
    @Column(name = "SLDETAIL_DESCRIPTION", length = 2048)
    private String slDetailDescription;
    @Basic(optional = false)
    @Column(name = "SLDETAIL_ORDER_NUMBER", columnDefinition = "tinyint UNSIGNED default 0", nullable = false)
    private short slDetailOrderNumber;
    @JoinColumn(name = "RBH_RISK_CATEGORY", referencedColumnName = "CATEGORY_ID")
    @ManyToOne(fetch = FetchType.LAZY)
    private Category category;
    @JoinColumn(name = "RBH_RISK_SEVERITY_LEVEL", referencedColumnName = "SEVERITY_LEVEL_ID", nullable = false)
    @ManyToOne(fetch = FetchType.LAZY)
    private SeverityLevel severityLevel;
    @OneToMany(mappedBy = "severityLevelDetail", fetch = FetchType.LAZY)
    @Cascade({CascadeType.DETACH})
    private List<RiskData> riskDataList;

    public Short getSldetailId() {
        return sldetailId;
    }

    public void setSldetailId(Short sldetailId) {
        this.sldetailId = sldetailId;
    }

    public String getSlDetailExplanation() {
        return slDetailExplanation;
    }

    public void setSlDetailExplanation(String slDetailExplanation) {
        this.slDetailExplanation = slDetailExplanation;
    }

    public String getSlDetailDescription() {
        return slDetailDescription;
    }

    public void setSlDetailDescription(String slDetailDescription) {
        this.slDetailDescription = slDetailDescription;
    }

    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    public SeverityLevel getSeverityLevel() {
        return severityLevel;
    }

    public void setSeverityLevel(SeverityLevel severityLevel) {
        this.severityLevel = severityLevel;
    }

    @XmlTransient
    public List<RiskData> getRiskDataList() {
        return riskDataList;
    }

    public void setRiskDataList(List<RiskData> riskDataList) {
        this.riskDataList = riskDataList;
    }

    public short getSlDetailOrderNumber() {
        return slDetailOrderNumber;
    }

    public void setSlDetailOrderNumber(short slDetailOrderNumber) {
        this.slDetailOrderNumber = slDetailOrderNumber;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sldetailId != null ? sldetailId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SeverityLevelDetail)) {
            return false;
        }
        SeverityLevelDetail other = (SeverityLevelDetail) object;
        if ((this.sldetailId == null && other.sldetailId != null) || (this.sldetailId != null && !this.sldetailId.equals(other.sldetailId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.rbh.risk.entity.SeverityLevelDetail[ sldetailId=" + sldetailId + " ]";
    }
}
